<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
         contentType="text/html;charset=utf-8" %>
<%@ include file="/common/taglibs.jsp" %>

<s:action name="product-order!view" var="view" executeResult="false"/>
<head>
    <title>订单详情</title>
</head>

<div id="wrapper">
    <c:set var="left">productOrder</c:set>
    <%@ include file="/include/left/financial.jsp" %>

    <div id="page-wrapper" class="gray-bg">

        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>订单列表</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="${ctx}/productOrder/">财务管理</a>
                    </li>
                    <li>
                        <a>订单管理</a>
                    </li>
                    <li class="active">
                        <strong>订单详情</strong>
                    </li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight ecommerce">
            <div class="home_block clearfix orderMain">


                <div class="order-info-table ">
                    <div class="order-hd">
                        <span>订单流程 </span>
                        <input type="button" class="btn btn-sm btn-info" onclick="exportExcel();"  value="导出excel"/>
                    </div>
                    <table class="table table-hover border">
                        <thead>
                        <tr>
                            <th>操作时间</th>
                            <th>信息</th>
                        </tr>
                        </thead>
                        <tbody>
                        <s:action name="order-step!list" executeResult="false" var="orderStepList"
                                  ignoreContextParams="true">
                            <s:param name="query.productOrderId">${view.productOrder.id}</s:param>
                            <s:param name="query.order">addTime</s:param>
                            <s:param name="query.desc">false</s:param>
                        </s:action>

                        <s:iterator value="%{#orderStepList.orderSteps}" var="orderStep">
                            <tr>
                                <td>
                                    <s:date name="%{addTime}" format="yyyy-MM-dd HH:mm"></s:date>
                                </td>
                                <td>${state}</td>
                            </tr>
                        </s:iterator>
                        </tbody>
                    </table>
                </div>

                <div class="order-hd">
                <span>订单状态:
                    <em class="label label-success">
                        ${view.productOrder.statements}
                    </em>
                </span>
                </div>

                <div class="order-info-mod clearfix">

                    <dl class="order-info  ">
                        <dt><span>买家信息</span></dt>
                        <dd>
                            <p><label>联系人</label> <span>${view.productOrder.addrName}</span></p>
                            <p><label>手机号</label> <span>${view.productOrder.addrMobile}</span></p>
                            <p><label>收货地址</label>
                                <span>${view.productOrder.province}${view.productOrder.city}${view.productOrder.district}${view.productOrder.address}</span>
                            </p>
                        </dd>
                    </dl>

                    <c:if test="${view.productOrder.state != 0}">
                        <dl class="order-info">
                            <dt><span>付款信息</span></dt>
                            <dd>
                                <p><label>付款方式</label><span><c:if test="${view.productOrder.payment==null || view.productOrder.payment==''}">暂无</c:if><c:if test="${view.productOrder.payment==0}">支付宝支付</c:if><c:if
                                        test="${view.productOrder.payment==1}">微信支付</c:if></span></p>
                                <p><label>订单金额</label> <span>￥${view.productOrder.price}</span></p>
                            </dd>
                        </dl>
                    </c:if>

                </div>

                <div class="order-info-table ">
                    <div class="order-hd">
                        <span>订单信息 </span>
                    </div>
                    <div class="store">
                        订单编号: <span>${view.productOrder.no}</span>
                    </div>

                    <table class="table table-hover border">
                        <thead>
                        <tr>
                            <th>商品</th>
                            <th>详细商品</th>
                            <th>单价</th>
                            <th>数量</th>
                            <th>商品合计</th>
                        </tr>
                        </thead>
                        <tbody>

                        <s:action name="order-item!list" executeResult="false" var="orderItemList"
                                  ignoreContextParams="true">
                            <s:param name="query.productOrderId">${view.productOrder.id}</s:param>
                            <s:param name="query.order">addTime</s:param>
                            <s:param name="query.desc">true</s:param>
                        </s:action>

                        <s:iterator value="%{#orderItemList.orderItems}" var="orderItem">
                            <tr>
                                <td class="prd"><img width="50" height="50" src=${product.img}>
                                    <p>${product.name}</p>
                                </td>
                                <td>${orderItem.productItem.title}</td>
                                <td>${orderItem.productItem.price}</td>
                                <td>${quantity}</td>
                                <td>${price}</td>
                            </tr>
                        </s:iterator>

                        <tr>
                            <td colspan="7">备注：<c:if
                                    test="${view.productOrder.remark==null ||view.productOrder.remark=='' }">暂无信息</c:if>
                                ${view.productOrder.remark}</td>
                        </tr>
                        <tr class="heji">
                            <td colspan="7" style="text-align: right">合计价格：<span>${view.productOrder.price}</span></td>
                        </tr>
                        </tbody>
                    </table>
                </div>

            </div>

        </div>

        <%@ include file="/common/footer.jsp" %>

    </div>

</div>

<%@ include file="/common/scripts.jsp" %>
<%@ include file="/common/script/cxcalendar.jsp" %>
<script src="${dll}/api/assets/layer/mobile/layer.js"></script>
<script>

    /**
     * 导出到excel
     */
    function exportExcel() {
        $.ajax({
            url: "${ctx}/product-order!exportExcel.action",
            type: "post",
            data: {
                'query.no': '${view.productOrder.no}',
            },
            dataType: "json",
            success: function (result) {
                if(result.status==1 || result.status=='1'){
                    window.open(result.url);
                }else {
                    layer.msg(result.msg);
                }
            }
        });
    }

</script>

